package initialization

import (
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
	"log"
	"server-admin-api/models"
)

const Url = "./resources/db/data.db3"

func InitSqlite() *gorm.DB {
	db, err := gorm.Open(sqlite.Open(Url), &gorm.Config{})
	if err != nil {
		log.Fatalf("初始化SQLite连接失败: %s\n", err.Error())
	}

	db.AutoMigrate(&models.Group{})

	return db
}